package com.graplo.gwtgaefb.client;

import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;

/**
 *
 * @author Dawid Ostrowski
 *
 * This class contains helper methods for most frequent usage of fb api
 * If you want to have the full control of parameters and FB API methods
 * use FacebookClient  class
 *
 * @see FacebookClient
 *
 */
public class HandyFacebookClient {

	/**
	 * Helper method  for creating dialog feed. It internally uses {@link FacebookClient#ui(String params, ResponseHandler reponseHandler)}
	 *
	 * @param name - Shown as a first text in a feed dialog
	 * @param caption - Shown as a second text in a feed dialog
	 * @param description - Shown as a third text in a feed dialog
	 * @param link - Url like: http://apps.facebook.com/gwtgaefb/
	 * @param picture - Url to picture. Like: http://gwtgaefb.appspot.com/gfx/hat.png
	 * @param responseHandler - handle method of this object will be invoked when response arrives
	 * @see <a href="http://developers.facebook.com/docs/reference/dialogs/feed/">http://developers.facebook.com/docs/reference/dialogs/feed/</a>
	 *
	 * This window looks like this:
	 * <img src="doc-files/dialogfeed.png">
	 */
	public static void dialogFeed(String name, String caption, String description, String link, String picture, ResponseHandler responseHandler) {
		JSONObject params = new JSONObject();
		params.put("method", new JSONString("feed"));
		params.put("name", new JSONString(name));
		params.put("caption", new JSONString(caption));
		params.put("description", new JSONString(description));
		params.put("link", new JSONString(link));
		params.put("picture", new JSONString(picture));
		FacebookClient.ui(params.getJavaScriptObject(), responseHandler);
	}

	/**
	 * To enable the user to select who they would like to send a request to you can invoke the Request Dialog
	 *
	 * @param message - shown in the request
	 * @param responseHandler - handle method of this object will be invoked when response arrives
	 * @see <a href="http://developers.facebook.com/docs/reference/dialogs/requests/">http://developers.facebook.com/docs/reference/dialogs/requests/</a>
	 */
	public static void dialogRequestMultiFriend(String message, ResponseHandler responseHandler) {
		JSONObject params = new JSONObject();
		params.put("method", new JSONString("apprequests"));
		params.put("message", new JSONString(message));
		FacebookClient.ui(params.getJavaScriptObject(), responseHandler);
	}

}
